package com.jiyun.purse.service.impl;

import com.jiyun.pojo.purse.Attestation;
import com.jiyun.purse.mapper.AttestationMapper;
import com.jiyun.purse.service.AttestationService;
import com.jiyun.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AttestationServiceImpl implements AttestationService {
    @Autowired
    private AttestationMapper attestationMapper;

    /**
     * 根据用户ID查询认证信息
     *
     * @param userId 用户ID
     * @return 包含认证信息的Result对象
     */
    @Override
    public Result findAttestation(Integer userId) {
        return Result.ok(attestationMapper.findAttestation(userId));
    }

    /**
     * 添加新的认证信息
     *
     * @param attestation 认证对象，包含认证信息
     * @return 包含新增认证信息的Result对象
     */
    @Override
    public Result addAttestation(Attestation attestation) {
        attestation.setIsDelete(0); // 设置认证的未删除状态
        return Result.ok(attestationMapper.addAttestation(attestation));
    }
}
